package dto

type Pagination struct {
	PageIndex int `form:"pageIndex"  search:"-"`
	PageSize  int `form:"pageSize"  search:"-"`
	// 兼容
	Index int `form:"index"  search:"-"`
	Size  int `form:"size"  search:"-"`
}

func (m *Pagination) GetPageIndex() int {
	if m.PageIndex <= 0 && m.Index <= 0 {
		m.PageIndex = 1
	}
	if m.PageIndex <= 0 {
		return m.Index
	}
	return m.PageIndex
}

func (m *Pagination) GetPageSize() int {
	if m.PageSize <= 0 && m.Size <= 0 {
		m.PageSize = 10
	}
	if m.PageSize <= 0 {
		return m.Size
	}
	return m.PageSize
}

type Page struct {
	Records   interface{} `json:"records"`
	Total     int64       `json:"total"`
	PageSize  int         `json:"size"`
	PageIndex int         `json:"current"`
	Pages     int64       `json:"pages"`
	Other     interface{} `json:"other"`
}
